﻿using System.Data;
using Dapper;
using DataServer.ApplicationLib.Entities;
using Swimj.DataCore;

namespace DataServer.ApplicationLib.Repositories
{
    public class DataConfigRepository : IDataConfigRepository
    {
        private readonly IDbConnection _dbConnection;

        public DataConfigRepository(IDbConnection dbConnection)
        {
            _dbConnection = dbConnection;
        }

        public Task<Tuple<IEnumerable<DataConfigEntity>, int>> QueryFilterByPageAsync(ConditionCollection conditions, int pageIndex, int pageSize)
        {
            throw new NotImplementedException();
        }

        public Task<Tuple<IEnumerable<DataConfigEntity>, int>> QueryFilterByOrderPageAsync(ConditionCollection conditions, string order, string? sort, int pageIndex,
            int pageSize)
        {
            throw new NotImplementedException();
        }

        public Task<IEnumerable<DataConfigEntity>> QueryFilterAsync(ConditionCollection conditions)
        {
            throw new NotImplementedException();
        }

        public async Task<DataConfigEntity> GetByCodeAsync(string configCode)
        {
            var sql = @"select config.Id,
       ConfigCode,
       ConfigName,
       DataTable,
       CheckWay,
       Sort,
       Description
from DS_DATACONFIG config
where config.ConfigCode = @configCode";

            return await _dbConnection.QueryFirstOrDefaultAsync<DataConfigEntity>(sql,
                new { configCode = configCode });
        }

        public Task UpdateAsync(DataConfigEntity dataBaseEntity)
        {
            throw new NotImplementedException();
        }

        public Task<DataConfigEntity> GetAsync(Guid id)
        {
            throw new NotImplementedException();
        }

        public Task InsertAsync(DataConfigEntity dataBaseEntity)
        {
            throw new NotImplementedException();
        }
    }
}